import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  //  {
  //   title: '人员id',
  //   align:"center",
  //   dataIndex: 'personId'
  //  },
   {
    title: '学/工号',
    align:"center",
    dataIndex: 'personCode'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'personName'
   },
   {
    title: '部门名称',
    align:"center",
    dataIndex: 'personDepartmentName'
   },
    {
     title: '通道',
     align:"center",
     dataIndex: 'channelName'
    },
    {
     title: '门名称',
     align:"center",
     dataIndex: 'doorName'
    },
   {
    title: '设备序列号',
    align:"center",
    dataIndex: 'deviceSn'
   },
   {
    title: '设备名称',
    align:"center",
    dataIndex: 'deviceName'
   },
  //  {
  //   title: '预留',
  //   align:"center",
  //   dataIndex: 'addrName'
  //  },
   {
    title: '刷卡方式',
    align:"center",
    dataIndex: 'accessMethod',
    customRender: ({ text }) => {
      return render.renderDict(text, 'accessMethod');
    },
   },
   {
    title: '刷卡卡号',
    align:"center",
    dataIndex: 'cardNo'
   },
   {
    title: '图像抓拍',
    align:"center",
    dataIndex: 'snapLink',
    slots: { customRender: 'img' },
   },
   {
    title: '通行时间',
    align:"center",
    // sorter: true,
    dataIndex: 'accessDate',
    /* customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    }, */
   },
  //  {
  //   title: '通行序号',
  //   align:"center",
  //   dataIndex: 'passingNo'
  //  },
   {
    title: '是否离线',
    align:"center",
    dataIndex: 'isOfflineSeed',
    customRender: ({ text }) => {
      return render.renderDict(text, 'isOfflineSeed');
    },
   },
   {
    title: '上送时间',
    align:"center",
    dataIndex: 'seedDate'
   },
   {
    title: '体温',
    align:"center",
    dataIndex: 'temperature'
   },
];
//列表数据
export const totalColumns: BasicColumn[] = [
   {
    title: '部门名称',
    align:"center",
    dataIndex: 'departName'
   },
   {
    title: '在校人数',
    align:"center",
    dataIndex: 'inschool'
   },
   {
    title: '离校人数',
    align:"center",
    dataIndex: 'outschool'
   },
  
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "学/工号",
      field: 'personCode',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "姓名",
      field: 'personName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "部门",
      field: 'personDepartmentId',
      component: 'JSelectDept',
      componentProps:{
        isRadioSelection:true,
        checkable:false,
        multiple:false
      },
      dynamicRules: ({model,schema}) => {
            return [
                  // { message: '请选择部门!'},
            ];
      },
      //colProps: {span: 6},
 	},
	// {
  //     label: "设备序列号",
  //     field: 'deviceSn',
  //     component: 'Input',
  //     //colProps: {span: 6},
 	// },
	{
      label: "设备名称",
      field: 'deviceName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "刷卡方式",
      field: 'accessMethod',
      component: 'JDictSelectTag',
      componentProps:{
        dictCode:'accessMethod',
      },
      //colProps: {span: 6},
 	},
	// {
  //     label: "刷卡卡号",
  //     field: 'cardNo',
  //     component: 'Input',
  //     //colProps: {span: 6},
 	// },
     {
      label: "通行时间",
      field: "accessDate",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
      },
      //colProps: {span: 6},
	},
  {
    label: "通道",
    field: 'channelId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:'ss_channel,name,id',
    },
 },
	{
	    label: "陌生人",
	    field: 'atranger',
	    component: 'Input',
	    show:false,
	    defaultValue:'0'
	    //colProps: {span: 6},
	},
];

//查询数据
export const searchFormSchemaTotal: FormSchema[] = [
	{
      label: "部门",
      field: 'personDepartmentId',
      component: 'JSelectDept',
      componentProps:{
        isRadioSelection:true,
        checkable:false,
        multiple:false,
      },
      dynamicRules: ({model,schema}) => {
            return [
                  // { message: '请选择部门!'},
            ];
      },
 	},
	
	// {
  //     label: "设备名称",
  //     field: 'deviceName',
  //     component: 'Input',

 	// },
	// {
  //     label: "出入方式",
  //     field: 'accessMethod',
  //     component: 'JDictSelectTag',
  //     componentProps:{
  //       dictCode:'accessMethod',
  //     },
 	// },

  //    {
  //     label: "通行时间",
  //     field: "accessDate",
  //     component: 'RangePicker',
  //     componentProps: {
  //         valueType: 'Date',
  //     },
  //     //colProps: {span: 6},
	// },
	
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '人员id',
    field: 'personId',
    component: 'Input',
  },
  {
    label: '学/工号',
    field: 'personCode',
    component: 'Input',
  },
  {
    label: '姓名',
    field: 'personName',
    component: 'Input',
  },
  {
    label: '部门id',
    field: 'personDepartmentId',
    component: 'Input',
  },
  {
    label: '部门名称',
    field: 'personDepartmentName',
    component: 'Input',
  },
  {
    label: '设备id',
    field: 'deviceId',
    component: 'InputNumber',
  },
  {
    label: '设备序列号',
    field: 'deviceSn',
    component: 'Input',
  },
  {
    label: '设备名称',
    field: 'deviceName',
    component: 'Input',
  },
  {
    label: '预留',
    field: 'addrName',
    component: 'Input',
  },
  {
    label: '刷卡方式',
    field: 'accessMethod',
    component: 'Input',
  },
  {
    label: '刷卡卡号',
    field: 'cardNo',
    component: 'Input',
  },
  {
    label: '图像抓拍',
    field: 'snapLink',
    component: 'Input',
  },
  {
    label: '通行时间',
    field: 'accessDate',
    component: 'DatePicker',
  },
  {
    label: '通行序号',
    field: 'passingNo',
    component: 'Input',
  },
  {
    label: '是否离线',
    field: 'isOfflineSeed',
    component: 'Input',
  },
  {
    label: '上送时间',
    field: 'seedDate',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
  },
  {
    label: '体温',
    field: 'temperature',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];


export const atrangerColumns: BasicColumn[] = [
  
   {
    title: '设备序列号',
    align:"center",
    dataIndex: 'deviceSn'
   },
   {
    title: '设备名称',
    align:"center",
    dataIndex: 'deviceName'
   },
   {
    title: '刷卡方式',
    align:"center",
    dataIndex: 'accessMethod',
    customRender: ({ text }) => {
      return render.renderDict(text, 'accessMethod');
    },
   },
   {
    title: '刷卡卡号',
    align:"center",
    dataIndex: 'cardNo'
   },
   {
    title: '图像抓拍',
    align:"center",
    dataIndex: 'snapLink',
    slots: { customRender: 'img' },
   },
   {
    title: '通行时间',
    align:"center",
    // sorter: true,
    dataIndex: 'accessDate',
    /* customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    }, */
   },
  //  {
  //   title: '通行序号',
  //   align:"center",
  //   dataIndex: 'passingNo'
  //  },
   {
    title: '是否离线',
    align:"center",
    dataIndex: 'isOfflineSeed',
    customRender: ({ text }) => {
      return render.renderDict(text, 'isOfflineSeed');
    },
   },
   {
    title: '上送时间',
    align:"center",
    dataIndex: 'seedDate'
   },
   {
    title: '体温',
    align:"center",
    dataIndex: 'temperature'
   },
];

export const searchAtrangerFormSchema: FormSchema[] = [
	{
      label: "设备名称",
      field: 'deviceName',
      component: 'Input',
      //colProps: {span: 6},
 	},
     {
      label: "通行时间",
      field: "accessDate",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
      },
	},
  {
      label: "陌生人",
      field: 'atranger',
      component: 'Input',
      show:false,
      defaultValue:'1'
      //colProps: {span: 6},
  },
];

// 高级查询数据
export const superQuerySchema = {
  personId: {title: '人员id',order: 0,view: 'text', type: 'string',},
  personCode: {title: '学/工号',order: 1,view: 'text', type: 'string',},
  personName: {title: '姓名',order: 2,view: 'text', type: 'string',},
  personDepartmentId: {title: '部门id',order: 3,view: 'text', type: 'string',},
  personDepartmentName: {title: '部门名称',order: 4,view: 'text', type: 'string',},
  deviceId: {title: '设备id',order: 5,view: 'number', type: 'number',},
  deviceSn: {title: '设备序列号',order: 6,view: 'text', type: 'string',},
  deviceName: {title: '设备名称',order: 7,view: 'text', type: 'string',},
  addrName: {title: '预留',order: 8,view: 'text', type: 'string',},
  accessMethod: {title: '刷卡方式',order: 9,view: 'text', type: 'string',},
  cardNo: {title: '刷卡卡号',order: 10,view: 'text', type: 'string',},
  snapLink: {title: '图像抓拍',order: 11,view: 'text', type: 'string',},
  accessDate: {title: '通行时间',order: 12,view: 'date', type: 'string',},
  passingNo: {title: '通行序号',order: 13,view: 'text', type: 'string',},
  isOfflineSeed: {title: '是否离线',order: 14,view: 'text', type: 'string',},
  seedDate: {title: '上送时间',order: 15,view: 'datetime', type: 'string',},
  temperature: {title: '体温',order: 16,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
